# -*- coding: utf-8 -*-
# @Time : 2022/3/15 9:06
# @Author : Liuqing
# @File : 53)最大子数组的和.py
# @Software : PyCharm

class Solution(object):
    def maxSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        for i in range(1, len(nums)):
            if nums[i-1] > 0:
                nums[i] += nums[i-1]
        return max(nums)


if __name__ == '__main__':
    print(Solution().maxSubArray([-2,1,-3,4,-1,2,1,-5,4]))
